//#include <stdlib.h>
#include <errno.h>
#include <sys/ioctl.h>
//#include <fcntl.h>
#include <libv4l2.h>


int __xioctl(int fd, int request, void * arg, int wrapper ) {
	int r;
	if(wrapper) r = v4l2_ioctl(fd, request, arg);
	else do r = ioctl(fd, request, arg); while (-1 == r && EINTR == errno);
	return r;
}

int _xioctl(int fd, int request, void * arg) {
	int r;
	//do r = ioctl(fd, request, arg); while (-1 == r && EINTR == errno);
	r = v4l2_ioctl(fd, request, arg);
	return r;
}

int _xioctl_perror(int fd, char * req, int request, void * arg) {
	int r;
	do r = ioctl(fd, request, arg); while (-1 == r && EINTR == errno);
	//if( -1 == r ) perror("VIDIOC_QUERYCAP");
	return r;
}